package com.yanqu.road.server.timer;

import com.yanqu.road.entity.player.PlayerState;
import com.yanqu.road.server.GameServer;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.config.PassRoadMgr;
import com.yanqu.road.server.manger.log.LogMgr;
import com.yanqu.road.server.manger.player.GamePlayerMgr;
import com.yanqu.road.utils.executor.GeneralTask;

public class PlayerOnlineCountSaveTask extends GeneralTask {

	@Override
	public void doRun() {
		int activeNum = 0;
		for(GamePlayer player: GamePlayerMgr.getCopyPlayerList()){
			if(player.getState()== PlayerState.ONLINE){
			  activeNum++;
			}
		}
		LogMgr.addLogOnlineNum(GameServer.getInstance().getServerId(), activeNum, System.currentTimeMillis());

		// 顺带检测需要移除的关卡id
		PassRoadMgr.checkWillBeRemovePassId();
	}
}
